import Vue from 'vue'
import App from './App.vue'
import store from './store'
import router from './router'
import { getToken, setToken } from '@/utils/auth'
import { login } from '@/api/auth'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import dataV from '@jiaminghi/data-view'

import './assets/common.css'
import VueSuperSlide from 'vue-superslide'
Vue.use(VueSuperSlide)

Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(dataV)

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
  let token = getToken()
  // let url_arr = window.location.href.split('#')
  // let url_arr1 = url_arr[0].split('?')
  //   if(url_arr.length >1 && url_arr1.length >1) {
  //     window.location.href = (url_arr1[0]  + '#' +url_arr[1] + '?' + url_arr1[1])
  // }
  if(!token && to.meta.requiresAuth) {
      next()
  }else{
      next()
  }
})
new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app')
